package com.nx.samuel.java_spi;

import com.nx.samuel.java_spi.api.JdkSpiServiceInterface;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * 不能按需加载
 * 不够灵活，不能动态的AOP和IOC
 * dubbo SPI
 */
public class JdkSpiMain {

    public static void main(String[] args) {
        ServiceLoader<JdkSpiServiceInterface> serviceLoader = ServiceLoader.load(JdkSpiServiceInterface.class);
        Iterator<JdkSpiServiceInterface> iterator = serviceLoader.iterator();
        while (iterator.hasNext()) {
            JdkSpiServiceInterface spiInterface = iterator.next();
            spiInterface.getColor();
        }
    }
}
